// Notice/index控制器
define('noticeIndexController', ['angular','jquery'], function (angular,$) {
    var module = angular.module('controllers');
    module.controller('noticeIndexController', ['$scope','$rootScope','$filter','noticeServers', function ($scope,$rootScope,$filter,noticeServers) {
        $scope.formData={
            type:"",
            remind:"",
            state:"",
            user_id:$rootScope.user.id
        };
        $scope.noticeForm=function(){
                $scope.formData = $filter('simplifyJsonFilter')($scope.formData);
                noticeServers.noticeList($scope.formData).then(function(data) {
                    $scope.noticeData=data.data;
                });
        };
        $scope.noticeForm();
        // 修改提醒
        $scope.edit_notice=function(data){
            $scope.editData=angular.copy(data);
            $("#myModal").modal('show');
        };
        $scope.editNoticeForm=function(){
            noticeServers.editNotice($scope.editData).then(function(data) {
                $scope.noticeForm();
                $("#myModal").modal('hide');
            });
        };
        $scope.del_notice=function(data){
            if(confirm('确定删除?')===false)
                return false;
            noticeServers.delNotice(data).then(function(data) {
                $scope.noticeForm();
            });
        };
    }]);
});